﻿<Button @onclick="@Show">Dialog</Button>

@code {
    var option = new DialogOption()
    {
        Title = "利用代码关闭弹出框",
    };
    option.BodyTemplate = DynamicComponent.CreateComponent<Button>(new KeyValuePair<string, object>[]
    {
        new KeyValuePair<string, object>(nameof(Button.Text), "点击关闭弹窗"),
        new KeyValuePair<string, object>(nameof(Button.OnClick), EventCallback.Factory.Create<MouseEventArgs>(this, () => {
            option.Dialog?.Close();
        }))
    }).Render();
    DialogService.Show(option);
}
